
package com.basic.library.brvah;

import android.view.View;

import com.basic.library.utils.ButtonUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.SimpleClickListener;

/**
 * @author yj
 * @description 解决列表item重复点击
 */
public abstract class MSimpleClickListener extends SimpleClickListener {

    private boolean isFD = true;
    private long diff = 680;

    public MSimpleClickListener(boolean isFD) {
        this.isFD = isFD;
    }

    public MSimpleClickListener(long diff) {
        this.diff = diff;
    }

    public MSimpleClickListener() {
    }

    @Override
    public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {
        if (isFD) {
            if (!ButtonUtils.isFastDoubleClick(position, diff)) {
                onItemClickDiff(baseQuickAdapter, view, position);
            }
        } else {
            onItemClickDiff(baseQuickAdapter, view, position);
        }
    }

    @Override
    public void onItemChildClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {
        if (isFD) {
            if (!ButtonUtils.isFastDoubleClick(position, diff))
                onItemChildClickDiff(baseQuickAdapter, view, position);
        } else {
            onItemChildClickDiff(baseQuickAdapter, view, position);
        }
    }

    public abstract void onItemClickDiff(BaseQuickAdapter baseQuickAdapter, View view, int position);

    public abstract void onItemChildClickDiff(BaseQuickAdapter baseQuickAdapter, View view, int position);

    @Override
    public void onItemLongClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {

    }

    @Override
    public void onItemChildLongClick(BaseQuickAdapter baseQuickAdapter, View view, int position) {

    }
}
